<%@page contentType="text/html; charset=UTF-8" language="java"%>
<%@page import="com.travelsky.airchina.boarding.util.PageViewUtil"%>
<%@page import="com.travelsky.airchina.boarding.util.PageUtil"%>
<%@include file="/common/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>管理中心 - 新闻列表 </title>
	<meta name="robots" content="noindex, nofollow"/>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link href="${ctx}/css/system/general.css" rel="stylesheet" type="text/css" />
	<link href="${ctx}/css/system/main.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="${ctx}/js/checkFrameSet.js"></script>
	<script type="text/javascript" src="${ctx}/js/jquery-1.4.min.js"></script>
	<script type="text/javascript" src="${ctx}/js/json.min.js"></script>
	<script type="text/javascript" src="${ctx}/js/operationTip.js"></script>
	<script language="JavaScript">
	    function updateStatus(newsId,newsStatusCode){
			$.getJSON("${ctx}/system/news/updatestatus", { id: newsId,status:newsStatusCode }, function(data) {
		  	    if(data.updateFlag==true){
		  	       if(newsStatusCode==${NEWS_STATUS_AUDIT_PUBLISH}){
		  	          $("#status"+newsId).text("审核发布");
		  	          $("#statusOperation"+newsId).html("<a href=\"javascript:void(0);\" onclick=\"javascript:updateStatus("+newsId+",${NEWS_STATUS_AUDIT_NOT_PASS});\" title=\"审核不通过\">审核不通过</a>");
		  	       }else if(newsStatusCode==${NEWS_STATUS_AUDIT_NOT_PASS}){
		  	          $("#status"+newsId).text("审核不通过");  
		  	          $("#statusOperation"+newsId).html("<a href=\"javascript:void(0);\" onclick=\"javascript:updateStatus("+newsId+",${NEWS_STATUS_AUDIT_PUBLISH});\" title=\"审核通过\">审核通过</a>");
		  	       }else if(newsStatusCode==${NEWS_STATUS_AUDIT_ARCHIVE}){
		  	          $("#status"+newsId).text("归档");
		  	          $("#statusOperation"+newsId).html("<a href=\"javascript:void(0);\" onclick=\"javascript:updateStatus("+newsId+",${NEWS_STATUS_AUDIT_PUBLISH});\" title=\"审核通过\">审核通过</a> ");
		  	       }
		  	       $("#statusOperationTip"+newsId).text("操作成功");
		  	       $("#statusOperationTip"+newsId).fadeIn("normal",function(){$("#statusOperationTip"+newsId).fadeOut(2000)});
		  	    }else{
		  	       $("#statusOperationTip"+newsId).text("操作失败");
		  	       $("#statusOperationTip"+newsId).fadeIn("normal",function(){$("#statusOperationTip"+newsId).fadeOut(2000)});
		  	    }
			});
	    }
	</script>
</head>
<body>
<h1>
<c:if test="${USER_OPERATION_URIS_MAP['/system/news']!=null}">
<span class="action-span"><a href="${ctx}/system/news">新建新闻</a></span>
</c:if>
<span class="action-span1"><a href="#">管理中心</a>  - 新闻列表 </span>
<div style="clear:both"></div>
</h1>
<%
String operationFlag = (String)request.getAttribute("operationFlag");
if(operationFlag!=null){
   if("t".equals(operationFlag)){
%>
  <ul class="actionMessage">
    <li>操作成功
    </li>
  </ul>
<%
   }else if("f".equals(operationFlag)){
%>
  <ul class="errorMessage">
    <li>操作失败
    </li>
  </ul>
<%
   }
}
%>
<form method="post" action="" id="listForm" name="listForm">
<div class="list-div" id="listDiv">
<table width="100%" cellpadding="3" cellspacing="1" id="listTable">
  <tr>
    <th>序号</th>
    <th>新闻标题</th>
    <th>所在栏目</th>
    <th>创建时间</th>
    <th>状态</th>
    <th>操作</th>
  </tr>
  <c:forEach items="${list}" var="itemTemp" varStatus="statusTemp">
  <tr>
    <td class="first-cell">
    ${statusTemp.index+1}
    </td>
    <td class="first-cell">
    <c:choose>
       <c:when test="${fn:length(itemTemp.title)>25}">
    <span title="${itemTemp.title}">${fn:substring(itemTemp.title,0,24)}...</span>
       </c:when>
       <c:otherwise>
    ${itemTemp.title}
       </c:otherwise>
    </c:choose>
    </td>
    <td align="center">${itemTemp.columnName}</td>
    <td align="center"><fmt:formatDate value="${itemTemp.createdTime}" type="date"/></td>
    <td align="center">
    <div class="statusDiv" id="statusDiv${itemTemp.id}">
	    <span id="status${itemTemp.id}">
	    <c:choose>
	      <c:when test="${itemTemp.status==NEWS_STATUS_NO_AUDIT}">未审核</c:when>
	      <c:when test="${itemTemp.status==NEWS_STATUS_AUDIT_PUBLISH}">审核发布</c:when>
	      <c:when test="${itemTemp.status==NEWS_STATUS_AUDIT_NOT_PASS}">审核不通过</c:when>
	      <c:when test="${itemTemp.status==NEWS_STATUS_AUDIT_ARCHIVE}">已归档</c:when>
	      <c:otherwise>未知状态</c:otherwise>
	    </c:choose>
	    </span>
	    <div class="statusOperationTip" id="statusOperationTip${itemTemp.id}"></div>
    </div>
    </td>
    <td align="center">
      <a href="${ctx}/news/${itemTemp.id}/${itemTemp.title}" target="_blank" title="预览">预览</a>
      <c:if test="${USER_OPERATION_URIS_MAP['/system/news/view']!=null}"> | <a href="${ctx}/system/news/view/${itemTemp.id}" title="查看">查看</a></c:if>
      <c:if test="${USER_OPERATION_URIS_MAP['/system/news/update']!=null}"> | <a href="${ctx}/system/news/update/${itemTemp.id}" title="编辑">编辑</a></c:if>
      <c:if test="${USER_OPERATION_URIS_MAP['/system/news/delete']!=null}"> | <a href="${ctx}/system/news/delete/${itemTemp.id}" title="编辑">删除</a></c:if>
      <c:if test="${USER_OPERATION_URIS_MAP['/system/news/updatestatus']!=null}">
      <span id="statusOperation${itemTemp.id}">
	    <c:choose>
	      <c:when test="${itemTemp.status==NEWS_STATUS_NO_AUDIT}">
       | <a href="javascript:void(0);" onclick="javascript:updateStatus('${itemTemp.id}','${NEWS_STATUS_AUDIT_PUBLISH}');" title="审核发布">审核发布</a>
	      </c:when>
	      <c:when test="${itemTemp.status==NEWS_STATUS_AUDIT_PUBLISH}">
       | <a href="javascript:void(0);" onclick="javascript:updateStatus('${itemTemp.id}','${NEWS_STATUS_AUDIT_NOT_PASS}');" title="审核不通过">审核不通过</a>
	      </c:when>
	      <c:when test="${itemTemp.status==NEWS_STATUS_AUDIT_NOT_PASS}">
       | <a href="javascript:void(0);" onclick="javascript:updateStatus('${itemTemp.id}','${NEWS_STATUS_AUDIT_PUBLISH}');" title="审核通过">审核通过</a>
	      </c:when>
	      <c:when test="${itemTemp.status==NEWS_STATUS_AUDIT_ARCHIVE}">
       | <a href="javascript:void(0);" onclick="javascript:updateStatus('${itemTemp.id}','${NEWS_STATUS_AUDIT_PUBLISH}');" title="审核发布">审核发布</a>
	      </c:when>
	      <c:otherwise>
       | <a href="javascript:void(0);" onclick="javascript:updateStatus('${itemTemp.id}','${NEWS_STATUS_AUDIT_PUBLISH}');" title="审核发布">审核发布</a> |
      <a href="javascript:void(0);" onclick="javascript:updateStatus('${itemTemp.id}','${NEWS_STATUS_AUDIT_NOT_PASS}');" title="审核不通过">审核不通过</a>
	      </c:otherwise>
	    </c:choose>
	    </span>
	    </c:if>
    </td>
  </tr>
  </c:forEach>
  </table>
</div>
  <div class="page-navigation">
  <%
  PageUtil pageUtil = (PageUtil)request.getAttribute("pageUtil");
  PageViewUtil.printPage(out, pageUtil, "100%","listForm",request.getContextPath()+"/system/news/list","_self",false);
  %>
  </div>
</form>
</body>
</html>